const express = require('express');
const router = express.Router();
const { asyncHandle } = require('../getSendResult');
const {
    findBackstageSingleFile,
    findBackstageSingleFolder,
    updateBackstageSingleFile
} = require('../../services/backstage-file');


// 查询单个文件
router.get('/findBackstageSingleFile', asyncHandle(
    async (req, res, next) => {
        const fileId = req.query.fileId;
        const folderId = req.query.folderId;
        return await findBackstageSingleFile(folderId, fileId);
    }
))

// 查询单个文件夹
router.get('/findBackstageSingleFolder', asyncHandle(
    async (req, res, next) => {
        const folderId = req.query.folderId;
        return await findBackstageSingleFolder(folderId);
    }
));

// 更新文件的内容
router.post('/updateBackstageSingleFile', asyncHandle(
    async (req, res, next) => {
        const folderId = req.body.folderId;
        const fileId = req.body.fileId;
        const content = req.body.content;
        const name = req.body.name;
        return await updateBackstageSingleFile(folderId, fileId, content, name);
    }
))



module.exports = router;